import db_helper

class BaseAnalyzer:
    children = []
    description = ""
    def __init__(self, cursor, context={}, thread_name="") -> None:
        self.cursor = cursor
        self.time_range = db_helper.get_time_range(self.cursor)
        self.context = context
        self.thread_name = thread_name

    def analyze(self):
        result = {"name": self.__class__.description, "cost": self.get_result(), "subs": []}
        for child in self.children:
            sub = child(self.cursor, self.context, self.thread_name).analyze()
            result["subs"].append(sub)
        return result
    
    def get_result(self):
        raise NotImplementedError("get_result must be implemented")
    
    